package com.wifi.a007.wifiFragment;


import android.net.wifi.ScanResult;


import com.wifi.a007.R;

/**
 * Created by Administrator on 2017/6/30.
 */

public class HotInfo {
    private String BSSID;
    private String SSID;
    private String capabilities;
    private int frequency;  //user to get channel
    private int level; //use get imageResource
    private int imageResource;
    private String channel;

    public HotInfo(ScanResult  scanResult ) {
        this.BSSID = scanResult.BSSID;
        this.SSID  = scanResult.SSID;
        this.frequency =scanResult.frequency;
        this.channel=getChannel(scanResult.frequency);
        this.capabilities= scanResult.capabilities;
        this.level = scanResult.level;
        this.imageResource= chooseImage(scanResult.level);
    }
    public HotInfo(String BSSID, String SSID, String capabilities,int level,  int frequency ) {
        this.BSSID = BSSID;
        this.SSID  = SSID;
        this.level=level;
        this.capabilities= capabilities;
        this.frequency =frequency;
        this.channel=getChannel(frequency);
        this.imageResource = chooseImage(level);


    }

    public String getBSSID() {
        return BSSID;
    }

    public void setBSSID(String BSSID) {
        this.BSSID = BSSID;
    }

    public String getSSID() {
        return SSID;
    }

    public void setSSID(String SSID) {
        this.SSID = SSID;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getCapabilities() {
        return capabilities;
    }

    public void setCapabilities(String capabilities) {
        this.capabilities = capabilities;
    }

    public int  getFrequency() {
        return frequency;
    }

    public void setFrequency(int frequency) {
        this.frequency = frequency;
    }
    private  int  chooseImage(int level){
        int result;
        if(level >= -50){

            result=R.drawable.signal5;
        }else if(level >= -60){

            result=R.drawable.signal4;
        }
        else if(level >= -70){

            result=R.drawable.signal3;
        }
        else if(level >= -80){

            result=R.drawable.signal2;
        }else{

            result=R.drawable.signal1;
        }

        return result;
    }

    public int getImageResource() {
        return imageResource;
    }

    public void setImageResource(int imageResource) {
        this.imageResource = imageResource;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    private String getChannel(int  frequency){
            String channel="1";

            if(frequency == 2412){

                    channel="1";
             }else  if(frequency == 2417){

            channel="2";
             }else  if(frequency == 2422){

            channel="3";
            }else  if(frequency == 2427){

            channel="4";
            }else  if(frequency == 2432){

            channel="5";
            }else  if(frequency == 2437){

            channel="6";
            }else  if(frequency == 2442){

            channel="7";
            }else  if(frequency == 2447){

            channel="8";
            }else  if(frequency == 2452){

            channel="9";
            }else  if(frequency == 2457){

            channel="10";
            }else if(frequency == 2462){

            channel="11";
            }else if(frequency == 2467){

            channel="12";
            }else if(frequency == 2472){

            channel="13";
            }

            return channel;
    }


    }



